package cn.caipengbo.helloandroid;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.StringBuilderPrinter;
import android.view.View;
import android.widget.CheckBox;
import android.widget.Toast;

public class SimpleComponentActivity extends AppCompatActivity {

    private CheckBox checkBoxBasketball;
    private CheckBox checkBoxFootball;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_simple_component);
        checkBoxBasketball = (CheckBox) findViewById(R.id.cb_basketball);
        checkBoxFootball = (CheckBox) findViewById(R.id.cb_football);

    }

    public void confirm(View view) {
        StringBuffer stringBuffer = new StringBuffer();
        if (checkBoxBasketball.isChecked()) {
            stringBuffer.append(checkBoxBasketball.getText().toString() + ",");
        }
        if (checkBoxFootball.isChecked()) {
            stringBuffer.append(checkBoxFootball.getText().toString() + ",");
        }
        Toast.makeText(this, stringBuffer, Toast.LENGTH_SHORT).show();
    }
}
